import type { VbenFormSchema } from '#/adapter/form';

import { AiModelTypeEnum } from '@vben/constants';

import { getModelSimpleList } from '#/api/ai/model/model';

import { $t } from '#/locales';

export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      component: 'Input',
      fieldName: 'id',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'systemMessage',
      label: $t('views.ai.model.chatRole.systemMessage'),
      component: 'Textarea',
      componentProps: {
        rows: 4,
        placeholder: $t('views.ai.model.chatRole.systemMessagePlaceholder'),
      },
    },
    {
      component: 'ApiSelect',
      fieldName: 'modelId',
      label: $t('views.ai.common.modelName'),
      componentProps: {
        api: () => getModelSimpleList(AiModelTypeEnum.CHAT),
        labelField: 'name',
        valueField: 'id',
        allowClear: true,
        placeholder: $t('views.ai.common.modelNamePlaceholder'),
      },
      rules: 'required',
    },
    {
      fieldName: 'temperature',
      label: $t('views.ai.common.temperature'),
      component: 'InputNumber',
      componentProps: {
        placeholder: $t('views.ai.common.temperaturePlaceholder'),
        class: 'w-full',
        precision: 2,
        min: 0,
        max: 2,
      },
      rules: 'required',
    },
    {
      fieldName: 'maxTokens',
      label: $t('views.ai.common.maxTokens'),
      component: 'InputNumber',
      componentProps: {
        placeholder: $t('views.ai.common.maxTokensPlaceholder'),
        class: 'w-full',
        min: 0,
        max: 8192,
      },
      rules: 'required',
    },
    {
      fieldName: 'maxContexts',
      label: $t('views.ai.common.maxContexts'),
      component: 'InputNumber',
      componentProps: {
        placeholder: $t('views.ai.common.maxContextsPlaceholder'),
        class: 'w-full',
        min: 0,
        max: 20,
      },
      rules: 'required',
    },
  ];
}
